/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-09-12 13:26:44
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-09-15 10:40:56
 * @FilePath: \adminstration\src\Common\Router\MenuNavList\System\Attachment.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AnnexButton } from '../Common/options'

export const Attachment = async ({ url, OptionsEvent }) => {
    let data = {
        type: '系统配置',
        pageSize: 10,
        params: { pageIndex: 1 },
        hideInSearch: true,
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'fileType',
                title: '文件类型',
                rules: true,
                width: 100,
                valueType: 'select',
                valueEnum: BuiltInData.FileType,
            },
            commonTableList.tableName,
            {
                dataIndex: 'originalName',
                title: '原始文件名称',
                rules: true,
                width: 200,
                valueType: 'input',
                ellipsis: true,
            },
            {
                dataIndex: 'filePath',
                title: '文件存储路径',
                rules: true,
                width: 200,
                valueType: 'input',
                ellipsis: true,
            },
            {
                dataIndex: 'fileUrl',
                title: '访问地址',
                rules: true,
                width: 200,
                valueType: 'input',
                ellipsis: true,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 100,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { fileUrl } = record
                    return [
                        fileUrl && <AnnexButton OptionsEvent={OptionsEvent} key="see" url={fileUrl} title="查看附件" />,
                    ]
                },
            },
        ],
    }
    return data
}
